 IF EXISTS (SELECT * 
	   FROM   sysobjects 
	   WHERE  name = N'spm_StringLink')
	DROP FUNCTION spm_StringLink
GO

CREATE FUNCTION spm_StringLink
(
@Link varchar(64)=',',
@String1 varchar(256),
@String2 varchar(256),
@String3 varchar(256),
@String4 varchar(256),
@String5 varchar(256)
)
RETURNS varchar(2048)
AS
BEGIN
	declare @String varchar(2048)
	set @String=''
	if @String1 is not NULL
	begin
		set @String=@String+@String1+@Link
	end
	if @String2 is not NULL
	begin
		set @String=@String+@String2+@Link
	end
	if @String3 is not NULL
	begin
		set @String=@String+@String3+@Link
	end
	if @String4 is not NULL
	begin
		set @String=@String+@String4+@Link
	end
	if @String5 is not NULL
	begin
		set @String=@String+@String5+@Link
	end

	return @String	

END

GO 
print dbo.spm_StringLink(',','qsw','zj',null,null,null)
